package my.test.threads;

/**
 * @author LalitR
 */
public class ThreadState extends Thread {

	private static String str = "str";
	
	public static void main(String[] args) {
		ThreadState th = new ThreadState();
		th.start();
		th.changeStr();
		System.out.println(str);
		
		/**
		 * The ouput could be;
		 * str wiggy, str wiggy 0, str wiggy 0 1, str wiggy 0 1 2, str wiggy 0 1 2 3
		 * this is because once the start is called, the run method of the thread is
		 * invoked and depending on the cpu cycle of the machine the output might vary.
		 */
	}
	
	public void changeStr() {
		str = str + " wiggy";
	}
	
	public void run() {
		for (int i = 0; i < 4; i++)
			str = str + " " + i;
	}

}
